<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="js/ckform.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/showdate.js"></script>
	<script type="text/javascript" src="js/jquery.min.js?v=2.1.4"></script>
    <style type="text/css">
        body {font-size: 20px;
             padding-bottom: 40px;
             background-color:#e9e7ef;
             font-size:17px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
</head>
<h3><strong>博客信息：<span id="btitle"></span></strong></h3>
      <table class="table table-condensed">
               <tr>              
	              <td width="18%" height="30" align="center">博主名称：</td>
	              <td id="uname" width="82%" class="word_grey">
					 <%--博主名称--%>
				  </td>
	            </tr>
	            <tr>
	              <td height="28" align="center">邮箱</td>
	              <td height="28" id="email">fendou@fendou.com</td>
	            </tr>
				  <tr>
					  <td height="28" align="center">发布内容：</td>
					  <td height="28" id="content">的设计费看就看的房间</td>
				  </tr>
	            <tr>
	              <td height="28" align="center">发布时间：</td>
	              <td height="28" id="time" >2022-11-15 12:33:23</td>
	            </tr>
	  </table>

<h3><strong>全部评价内容：</strong></h3>
<table class="table table-bordered">
	<thead>
		<tr>
			<th>评价内容</th>
			<%--<th>评价人</th>--%>
			<th>评价时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody id="evaluates">
		<%--追加评论信息--%>

	</tbody>
</table>
</body>
<script type="text/javascript">
	$(function () {
		//函数调用 -- 博客详情的回显
		showBlogDetail(${param.id});
	})

	//函数 -- 博客详情回显
	function showBlogDetail(id) {
		$.ajax({
			url:"blog/detail",
			data:"id="+id,
			dataType:"json",
			success:function (obj) {
				console.log(obj);
				$("#btitle").text(obj.btitle);
				$("#uname").text(obj.user.uname);
				$("#email").text(obj.user.email);
				$("#content").text(obj.bcontent);
				$("#time").text(msToDateString(obj.date));

				//评论
				$("#evaluates").empty();
				$.each(obj.evaluates,function (i, eva) {
					$("#evaluates").append(
						'<tr>'+
							'<td>'+eva.econtent+'</td>'+
							'<td>'+msToDateString(eva.etime)+'</td>'+
							'<td><button type="button"  id="deletecomment">删除</button></td>'+
						'</tr>'
					)
				})
			}
		});
	}

	//函数 -- 毫秒值和日期字符串转换 把毫秒值转成日期字符串
	function msToDateString(ms) {
		var date = new Date(ms);
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var day = date.getDate();
		var hour = date.getHours();
		var minute = date.getMinutes();
		var second = date.getSeconds();

		if(month <= 9){
			month = "0" + month;
		}

		if(day <= 9){
			day = "0" + day;
		}

		if(hour <= 9){
			hour = "0" + hour;
		}

		if(minute <= 9){
			minute = "0" + minute;
		}

		if(second <= 9){
			second = "0" + second;
		}

		return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
	}
</script>
</html>
